package com.example.playlet.controller;

import cn.hutool.core.net.NetUtil;
import com.example.playlet.service.sensitive.impl.SensitiveWordsServiceImpl;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

//SpringBootApplication
@SpringBootApplication(scanBasePackages = {"com.example.playlet", "com.example.playlet.service"})
@MapperScan("com.example.playlet.mapper")
public class PlayletControllerApplication {
    private static final Logger logger = LoggerFactory.getLogger(PlayletControllerApplication.class);

    public static void main(String[] args) {

        // SpringApplication.run(PlayletControllerApplication.class, args);

        String applicationName = PlayletControllerApplication.class.getSimpleName();
        ConfigurableApplicationContext application = SpringApplication.run(PlayletControllerApplication.class, args);
        Environment env = application.getEnvironment();
        String port = env.getProperty("server.port");
        String contextPath = env.getProperty("server.servlet.context-path", "");
        String ip = NetUtil.getLocalhost().getHostAddress();

        String[] beanNames = application.getBeanDefinitionNames();
        logger.info("\n----------------------------------------------------------" +
                "\n\t " + applicationName + " start success! " +
                "\n\t Access URLs:" +
                "\n\t Local:      [ http://localhost:" + port + contextPath + " ]" +
                "\n\t External:   [ http://" + ip + ":" + port + contextPath + " ]" +
                "\n----------------------------------------------------------");

    }

}
